#!/usr/bin/env bash

# Get month diff
diffmonth=$(eww get monthshift)
if [[ "$1" == "up" ]]; then
  diffmonth=$(( $diffmonth - 1 ))
else
  diffmonth=$(( $diffmonth + 1 ))
fi
eww update monthshift="$diffmonth" &

# Get dates
dates=$(scripts/getfirstdayofmonth "$diffmonth")
dateSplitted=( $dates )
newTitle=$(date -d "${dateSplitted[3]}-${dateSplitted[2]}-${dateSplitted[1]}" "+%B %Y")

if [[ "$diffmonth" == "0" ]]; then
  dates=''
fi
eww update calendartitle="$newTitle" &
eww update calendar="$(scripts/calendarlayout $dates)"